package cn.bgs.service.impl;

import cn.bgs.pojo.PersonnelInfo;
import cn.bgs.mapper.PersonnelInfoMapper;
import cn.bgs.service.PersonnelInfoService;
import cn.bgs.util.OrderUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 乡镇人员信息表 服务实现类
 * </p>
 *
 * @author Mr.Zhao
 * @since 2022-08-08
 */
@Service
public class PersonnelInfoServiceImpl extends ServiceImpl<PersonnelInfoMapper, PersonnelInfo> implements PersonnelInfoService {

    @Autowired
    private PersonnelInfoMapper personnelInfoMapper;

    @Override
    public boolean updatedInfo(PersonnelInfo personnelInfo) {
        LocalDateTime localDateTime = LocalDateTime.now();
        personnelInfo.setUpdateTime(localDateTime);
        return personnelInfoMapper.updatedInfo(personnelInfo);
    }

    @Override
    public boolean addInfo(PersonnelInfo personnelInfo) {
        personnelInfo.setNumber(OrderUtils.getDateTime());
        personnelInfo.setDeleteFlag(0);
        LocalDateTime localDateTime = LocalDateTime.now();
        personnelInfo.setCreateTime(localDateTime);
        personnelInfo.setUpdateTime(localDateTime);
        return personnelInfoMapper.addInfo(personnelInfo);
    }

    @Override
    public Integer seletecount(QueryWrapper<PersonnelInfo> queryWrapper) {
        return personnelInfoMapper.selectCount(queryWrapper);
    }
}
